//
//  HWSearchCollectionViewCell.m
//  HappyWeekend
//
//  Created by lanou on 16/1/14.
//  Copyright © 2016年 com.mjykj.www. All rights reserved.
//

#import "HWSearchCollectionViewCell.h"
#define kCoverImageW 160
#define kCoverImageH (558 * 160 / 521)

@implementation HWSearchCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.coverImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kCoverImageW, kCoverImageH)];
        [self.contentView addSubview:self.coverImageView];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, _coverImageView.bottom + 5, _coverImageView.width - 10, 50)];
        [self.contentView addSubview:_titleLabel];
        
        self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.left, _titleLabel.bottom + 5, 70, 20)];
        [self.contentView addSubview:self.priceLabel];
        
        self.likeButton = [[HWIconLabelButton alloc] initWithFrame:CGRectMake(frame.size.width - 50, _priceLabel.top + 3, 40, 20)];
        [self.contentView addSubview:self.likeButton];
    }
    return self;
}


- (void)setModel:(HWSearchContentModel *)model
{
    _model = model;
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:model.cover_image_url]];
    self.titleLabel.text = model.name;
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font = [UIFont systemFontOfSize:14];
    self.priceLabel.text = [NSString stringWithFormat:@"￥%@",model.price];
    self.priceLabel.font = [UIFont systemFontOfSize:14];
    self.priceLabel.textColor = [UIColor greenColor];
    self.likeButton.likeLabel.text = [NSString stringWithFormat:@"%@",model.likes_count];
    self.likeButton.likeLabel.font = [UIFont systemFontOfSize:14];
}


@end
